home *** CD-ROM | disk | FTP | other *** search
/ Network Supervisor's Toolkit / Network Supervisor's Toolkit.iso / tools / lu62 / debug / pv.asm < prev    next >
Assembly Source File  |  1996-07-10  |  25KB  |  1,112 lines

  1. ;*
  2. ;*  File viewer
  3. ;*
  4. ;*  CopyRight 1995. Nicholas Poljakov all rights reserved.
  5. ;*
  6. .MODEL LARGE
  7. include c:\include\dos.inc
  8. include c:\include\bios.inc
  9. .STACK
  10. .DATA
  11. ;
  12.     PUBLIC Cnt_H, Cnt_L, b_ptr, h_cnt, t_cnt, h_buf, t_buf
  13.     PUBLIC v_addr, str, str_lt, v_page
  14.     PUBLIC _pv, set_scr0, line_up, line_dn, extable
  15.     PUBLIC page_up, page_dn, map_str, make_w
  16.     PUBLIC get_s_r, get_s_l, rt_buf, lf_buf, scroll, MapErr
  17.     PUBLIC deact_w, cal_cnt, nonek, SetVMem, GetFN, FilTitle
  18. ESCAPE  EQU 27
  19. UP      equ 48h
  20. DN      equ 50h
  21. PUP     equ 73
  22. PDN     EQU 81
  23. BUF_SIZ EQU 32000
  24. ;
  25. U_Y     equ 8
  26. U_X     equ 10
  27. X_SIZ   equ 70
  28. Y_SIZ   EQU 16
  29. TOP     equ 1
  30. BOTTOM  equ Y_SIZ - 4
  31. ;
  32. path    db  80 dup (?)
  33.         db  0
  34. fd      dw  0
  35. ;
  36. ; vars for buffers manipulation
  37. Cnt_H   dw  0  ; file pointer
  38. Cnt_L   dw  0  ; for LSEEK
  39. h_cnt   dw  0
  40. t_cnt   dw  0
  41. h_buf   dw  0
  42. t_buf   dw  0
  43. b_ptr   dw  0
  44. BuffSeg dw  0  ; buffer segment
  45. cur_cnt dw  0
  46. cur_ln  db  0
  47. array   dw  23 dup (?) ; Lengths of the strings
  48. buf_lt  dw  0
  49. str_lt  dw  0
  50. str     db 100 dup (?)
  51. ;
  52. ; vars for window
  53. ;
  54. v_page  db  0      ; video page
  55. w_off   dw  (U_Y - 1) *  160 + (U_X - 1) * 2
  56. siz_y   db  Y_SIZ - 2
  57. siz_x   db  X_SIZ - 2
  58. attrib  db  70h    ; attibute for window
  59. attrib1 db  70h    ; attibute for query
  60. attrib2 db  0fh    ; attibute for title
  61. attrib3 db  0fh    ; attibute for error message
  62. sksave  db  0
  63. ;
  64. v_addr  dw  0
  65. w_save  db  X_SIZ * Y_SIZ * 2 dup (?)
  66. svline  dw  80 dup (?)
  67. ;
  68. dcl0    db  'File : '
  69. dcl0lt  equ $ - dcl0
  70. dcl1    db  'Enter the file name please : '
  71. dcl1lt  equ  $ - dcl1
  72. dcl2    db  'Sorry... file not found !'
  73. dcl2lt  equ  $ - dcl2
  74. err2    DB      13,10,"Insufficient memory... Sorry!",13,10,"$"
  75. ;
  76. ; Call table
  77.  
  78. exkeys    DB      72,73,80,81,60  ; Extended key codes
  79. lexkeys   EQU     $-exkeys        ; Table of keys
  80. extable   DD      line_up
  81.           DD      page_up
  82.           DD      line_dn
  83.           DD      page_dn
  84.           DD      ResetFL
  85.           DD      nonek
  86. ;
  87. ;buff    db BUF_SIZ dup (?)
  88. .CODE
  89. _pv    proc  far
  90. ;
  91. ;       mov   ax, _DATA
  92. ;       mov   ds, ax
  93. ;
  94.         push  bp
  95.         mov   bp, sp
  96.         push  si
  97.         push  di
  98. ;
  99. ;  In [bp+6] -> Arg1     (offset Path_name)
  100. ;  in [bp+8] -> Arg2     (segment Path_name)
  101. ;
  102.  
  103.         call far ptr  SetVMem    ; Set addres of video memory
  104.  
  105. ; Allocate dynamic memory for file buffer
  106.  
  107.         @GetBlok 0FFFh                ; Try to allocate 64K
  108.         jnc     SaveBSeg
  109.         @DispStr err2                 ; else error and quit
  110.         jmp     short Main_exit
  111. SaveBSeg:
  112.         mov     BuffSeg,ax            ; Save buffer segment
  113.  
  114. RdFilN:
  115.         call far ptr  set_scr0   ; Set initial window
  116.         cmp   ax, 0
  117.         je    Reread
  118.         call far ptr  MapErr
  119.         jmp short RdFilN
  120. Reread:
  121.         mov   ah, 0      ; Keyboard
  122.         int   16h        ;     input
  123.         cmp   al, 0
  124.         je    Test_mv    ; Test if it's cursor move key
  125.         cmp   al, ESCAPE
  126.         jne   Reread
  127.         call far ptr  deact_w
  128. Main_exit:
  129. ;       @Exit            ; Exit if 'escape' pressed or error
  130.         mov     ax, 0    ; Return
  131.         mov     dx, 0    ;       code
  132.         pop     di
  133.         pop     si
  134.         pop     bp
  135.         ret
  136. ;
  137. Test_mv:
  138.         mov   al, ah     ; Test scan code
  139. ;
  140.         push    es
  141.         push    ds                    ; Load DS into ES
  142.         pop     es
  143.         mov     di,OFFSET exkeys      ; Load address and length of key list
  144.         mov     cx,lexkeys+1
  145.         cld
  146.         repne   scasb                 ; Find position
  147.         pop     es
  148.         sub     di,(OFFSET exkeys)+1  ; Point to key
  149.         shl     di,1                  ; Adjust pointer for word addresses
  150.         shl     di,1                  ; Adjust pointer for dword addresses
  151.         call    extable[di]           ; Call procedure
  152.         jmp     Reread
  153. _pv    endp
  154. ;
  155. line_up proc  far
  156.         push  es
  157.         mov   ax, b_ptr  ; current position in buffer
  158.         push  ax         ; save it
  159.         sub   ax, cur_cnt
  160.         mov   b_ptr, ax
  161.         call far ptr  get_s_l
  162.         cmp   ax, 0
  163.         je    Lu_contin
  164.         pop   ax         ; old position
  165.         mov   b_ptr, ax
  166.         jmp  short Lu_exit
  167. Lu_contin:
  168.         pop   ax         ; to restory SP
  169.         mov   al, -1
  170.         call far ptr  scroll
  171. ;
  172. ;  Shift array on the right
  173. ;
  174.         push  ds
  175.         pop   es
  176.         xor   bx, bx
  177.         mov   bl, cur_ln
  178.         mov   cx, bx
  179.         shl   bl, 1
  180.         mov   di, offset array
  181.         add   di, bx        ; point to end of the array
  182. ;
  183.         mov   ax, word ptr [di]
  184.         add   t_buf, ax     ; set t_buf value
  185. ;
  186.         mov   si, di
  187.         sub   si, 2         ; point to end  of array - 1
  188.         shl   cx, 1
  189.         std
  190.         rep  movsb
  191. ;
  192.         mov   bx, offset array
  193.         mov   ax, str_lt
  194.         mov   word ptr [bx], ax ; set first element
  195. ;
  196.         sub   h_buf, ax     ; set h_buf value
  197. ;
  198. ;
  199. ; Calculate the total length of mapped strings
  200. ;
  201. ;
  202.         call far ptr  cal_cnt
  203. ;
  204.         mov   ax, b_ptr   ; set new position
  205.         add   ax, cur_cnt
  206.         mov   b_ptr, ax
  207. ;
  208.         mov   ax, TOP
  209.         call far ptr  map_str
  210. Lu_exit:
  211.         mov   ax, 0
  212.         pop   es
  213.         ret
  214. line_up endp
  215. ;
  216. line_dn proc  far
  217.         push  es
  218.         call far ptr  get_s_r
  219.         cmp   ax, 0
  220.         jne   Ld_exit
  221.         mov   al, 1
  222.         call far ptr  scroll
  223.         mov   al, cur_ln
  224.         cmp   al, BOTTOM - 1
  225.         inc   al
  226.         mov   bx, ax
  227.         jb    M_str
  228.         mov   bx, offset array
  229.         mov   ax, word ptr [bx]
  230.         add   h_buf, ax
  231. ; Shift array left to one element
  232.         push  ds
  233.         pop   es
  234.         mov   di, offset array
  235.         mov   si, di
  236.         add   si, 2
  237.         mov   cx, BOTTOM - 1
  238.         shl   cx, 1
  239.         cld
  240.         rep  movsb
  241. ;
  242.         mov   bx, BOTTOM - 1
  243.         jmp   short Skip_sl
  244. M_str:
  245.         mov   cur_ln, al
  246. Skip_sl:
  247.         shl   bx, 1
  248.         mov   ax, str_lt
  249.         mov   array[bx], ax  ; save length of cur. string
  250. ;
  251.         sub   t_buf, ax
  252. ;
  253. ; Calculate the total length of mapped strings
  254. ;
  255. ;
  256.         call far ptr  cal_cnt
  257. ;
  258.         xor   ax, ax
  259.         mov   al, cur_ln
  260.         inc   al
  261.         call far ptr  map_str
  262. Ld_exit:
  263.         mov   ax, 0
  264.         pop   es
  265.         ret
  266. line_dn endp
  267. ;
  268. page_up proc  far
  269.         push  es
  270.         mov   cx, BOTTOM
  271. Pg_fill0:
  272.         push  cx
  273.         call far ptr  line_up
  274.         pop   cx
  275.         loop  Pg_fill0
  276. ;
  277.         mov   ax, 0
  278.         pop   es
  279.         ret
  280. page_up endp
  281. ;
  282. page_dn proc  far
  283.         push  es
  284. ;        mov   al, BOTTOM
  285. ;        call far ptr  scroll
  286.         mov   cx, BOTTOM
  287. Pg_fill:
  288.         push  cx
  289.         call far ptr  line_dn
  290.         pop   cx
  291.         loop  Pg_fill
  292. ;
  293.         mov   ax, 0
  294.         pop   es
  295.         ret
  296. page_dn endp
  297. ;
  298. make_w  proc  far
  299.         push  es
  300.         mov   ax, 10h
  301.         mov   bl, v_page
  302.         xor   bh, bh
  303.         mul   bx
  304.         add   v_addr, ax
  305.         cmp   sksave, 0
  306.         jne   ClearW
  307. ;
  308. ; Save window
  309. ;
  310.         mov   di, offset w_save
  311.         mov   si, w_off
  312.         push  ds
  313.         push  ds
  314.         pop   es
  315.         mov   ax, v_addr
  316.         mov   ds, ax
  317.         mov   cx, Y_SIZ
  318. S_cycl:
  319.         push  cx
  320.         push  si
  321.         mov   cx, X_SIZ * 2
  322.         cld
  323.         rep movsb
  324.         pop   si
  325.         add   si, 160
  326.         pop   cx
  327.         loop  S_cycl
  328. ;
  329.         pop   ds
  330. ;
  331. ;  Clear the window
  332. ;
  333. ClearW:
  334.         mov   ax, v_addr
  335.         mov   es, ax
  336.         mov   di, w_off
  337.         mov   ah, attrib
  338.         mov   al, 20h
  339.         mov   cx, Y_SIZ
  340. C_cycl:
  341.         push  cx
  342.         push  di
  343.         mov  cx, X_SIZ
  344.         rep  stosw
  345.         pop   di
  346.         add   di, 160
  347.         pop   cx
  348.         loop  C_cycl
  349. ;
  350. ;   Draw the border
  351. ;
  352.         mov   di, w_off
  353.         inc   di
  354.         inc   di
  355.         mov   al, 205
  356.         mov   ah, attrib
  357.         mov  cx, X_SIZ - 2
  358.         rep  stosw
  359.         mov   al, 186
  360.         mov   cx, Y_SIZ - 2
  361.         mov   di, w_off
  362.         add   di, 160
  363. D_cycl:
  364.         push  di
  365.         stosw
  366.         add   di, (X_SIZ - 2) * 2
  367.         stosb
  368.         pop   di
  369.         add   di, 160
  370.         loop  D_cycl
  371. ;
  372.         mov   di, w_off
  373.         add   di, (Y_SIZ - 1) * 160
  374.         inc   di
  375.         inc   di
  376.         mov   al, 205
  377.         mov  cx, X_SIZ - 2
  378.         rep  stosw
  379. ;
  380.         mov   di, w_off
  381.         mov   al, 201
  382.         stosw
  383.         add   di, (X_SIZ - 2) * 2
  384.         mov   al, 187
  385.         stosw
  386.         mov   di, w_off
  387.         add   di, (Y_SIZ - 1) * 160
  388.         mov   al, 200
  389.         stosw
  390.         add   di, (X_SIZ - 2) * 2
  391.         mov   al, 188
  392.         stosw
  393. ;
  394.         mov   ax, 0
  395.         pop   es
  396.         ret
  397. ;
  398. make_w  endp
  399. ;
  400. set_scr0 proc  far
  401.         push  es
  402. ;        call far ptr  GetFN
  403. ;        @OpenFil path, 0
  404. ;        jnc   M_win
  405. ;        mov   ax, -1
  406. ;
  407. ; Try to open command line file
  408. ;
  409. cmdchk:
  410. ;       mov     bl,es:[80h]           ; Get length
  411. ;       sub     bh,bh
  412. ;       mov     WORD PTR es:[bx+81h],0; Convert to ASCIIZ
  413.         les     bx, dword ptr [bp + 6]
  414.         push    ds
  415. ;       @OpenFil 82h,0,es             ; Open argument
  416.         @OpenFil bx,0,es             ; Open argument
  417.         pop     ds
  418.         jnc     M_win
  419.         mov     ax, -1
  420.         pop     es
  421.         ret                           ; error return
  422. M_win:
  423.         mov     fd, ax                ; save descriptor of file
  424.         mov     t_cnt, 1
  425. ;
  426.         call far ptr    rt_buf
  427.         mov     h_cnt, 0
  428. ;
  429.         call far ptr    make_w
  430.         call far ptr    FilTitle
  431. ;
  432.         mov   cx, Y_SIZ - 4
  433.         xor   ax, ax
  434. Set_cycl:
  435.         push  ax
  436.         call far ptr  get_s_r
  437.         cmp   ax, 0
  438.         je    Set_cy_cont
  439.         pop   ax
  440.         jmp short SetExit
  441. Set_cy_cont:
  442.         pop   ax
  443. ;
  444.         push  ax
  445.         mov   bx, t_buf      ; correct t_buf value
  446.         mov   ax, str_lt
  447.         sub   bx, ax
  448.         mov   t_buf, bx
  449.         pop   ax
  450. ;
  451.         mov   cur_ln, al    ; save number of current line
  452.         mov   bx, ax
  453.         shl   bx, 1
  454.         mov   dx, str_lt
  455.         mov   array[bx], dx ; save length of cur. line
  456.         inc   ax
  457.         push  ax
  458.         call far ptr  map_str
  459.         pop   ax
  460.         loop  Set_cycl
  461. ;
  462.         call far ptr  cal_cnt
  463. ;
  464. SetExit:
  465.         mov   ax, 0
  466.         pop   es
  467.         ret
  468. ;
  469. set_scr0 endp
  470. ;
  471. ;
  472. get_s_r proc  far
  473.         push  es
  474.         push  cx
  475.         cmp   t_buf, 0
  476.         jg    Get_contin
  477.         call far ptr  rt_buf
  478.         cmp   ax, -1
  479.         jne   Get_contin
  480.         pop   cx
  481.         pop     es
  482.         ret
  483. Get_contin:
  484.         mov   cx, t_buf
  485. ;       push  ds
  486. ;       pop   es
  487. ;       mov   di, b_ptr  ; pointer in buffer
  488.         les   di, dword ptr b_ptr   ; //12.2.92 external buffer//
  489.         mov   al, 0ah
  490.         cld
  491.         repne scasb
  492.         jz    Next_prc
  493. Next_prc:
  494. ;
  495.         mov   cx, di
  496.         mov   si, b_ptr
  497.         sub   cx, si
  498.         mov   str_lt, cx  ; Save length of string
  499. ;
  500.         cmp   cx, 100     ; Test upper length
  501.         jb    MvStr1
  502.         mov   cx, 99
  503. MvStr1:
  504.         push  ds
  505.         mov   ax, ds
  506.         mov   di, BuffSeg
  507.         mov   ds, di
  508.         mov   es, ax
  509.         mov   di, offset str
  510.         cld
  511.         rep movsb
  512.         pop   ds
  513. ;
  514.         mov   ax, str_lt
  515.         add   b_ptr, ax
  516. ;
  517.         mov   ax, 0
  518.         pop   cx
  519.         pop   es
  520.         ret
  521. get_s_r endp
  522. ;
  523. get_s_l proc  far
  524.         push  es
  525.         push  cx
  526.         cmp   h_buf, 0
  527.         jg    Get_l_contin
  528.         call far ptr  lf_buf
  529.         cmp   ax, -1
  530.         jne   Get_l_contin
  531.         pop   cx
  532.         pop   es
  533.         ret
  534. Get_l_contin:
  535.         mov   cx, h_buf
  536. ;       push  ds
  537. ;       pop   es
  538. ;       mov   di, b_ptr  ; pointer in buffer
  539.         les   di, dword ptr b_ptr ;//12.2.92 external buffer//
  540.         sub   di, 2      ; skip 0ah char.
  541.         sub   cx, 2      ; dec. corresponded length
  542.         mov   al, 0ah
  543.         std
  544.         repne scasb
  545. ;
  546.         jnz   Skip_sub_2 ; 0ah was't found...
  547.         add   di, 2      ; 0ah was found !
  548. Skip_sub_2:
  549.         mov   cx, b_ptr
  550.         sub   cx, di
  551.         jns   Sv_lt
  552.         neg   cx
  553. Sv_lt:
  554.         or    cx, cx
  555.         jnz   SvLen
  556.         mov   cx, 2       ; it's first null line
  557.         mov   di, 0       ; offset buff
  558. SvLen:
  559.         mov   str_lt, cx  ; Save length of string
  560. ;
  561.         mov   b_ptr, di
  562. ;
  563.         cmp   cx, 100     ; Test upper length
  564.         jb    MvStr2
  565.         mov   cx, 99
  566. MvStr2:
  567.         push  ds
  568.         mov   ax, ds
  569.         mov   si, BuffSeg
  570.         mov   ds, si
  571.         mov   es, ax
  572.         mov   si, di
  573.         mov   di, offset str
  574.         cld
  575.         rep movsb
  576.         pop   ds
  577. ;
  578.         mov   ax, 0
  579.         pop   cx
  580.         pop   es
  581.         ret
  582. get_s_l endp
  583. ;
  584. rt_buf  proc  far
  585.         push  es
  586.         push  bx
  587.         push  cx
  588.         push  dx
  589.         push  si
  590.         push  di
  591. ;
  592.         cmp   t_cnt, 0
  593.         jne   Rt_read
  594.         mov   ax, -1
  595.         jmp   Rt_exit
  596. ;
  597. Rt_read:
  598.         mov   cx, Cnt_H
  599.         mov   dx, Cnt_L
  600.         @MovePtrAbs fd     ; set file pointer
  601.         push  ds
  602.         mov   ax, BuffSeg
  603.         @Read 0, BUF_SIZ, fd, ax
  604.         pop   ds
  605.         jnc   Chk_count
  606.         mov   ax, -1
  607.         jmp   short Rt_exit
  608. Chk_count:
  609.         cmp   ax, BUF_SIZ ; full block ?
  610.         je    Rt_set_next
  611.         mov   t_cnt, 0    ; last block
  612.         cmp   ax, 0
  613.         jne   Cr_Cnt
  614.         mov   ax, -1
  615.         jmp   short Rt_exit
  616. Rt_set_next:
  617.         mov   t_cnt, 1     ; not last block
  618.         mov   cx, ax
  619.         mov   di, ax       ; offset buff
  620.         mov   ax, BuffSeg
  621.         mov   es, ax
  622.         mov   al, 0ah
  623.         std
  624.    repne scasb
  625.         cld
  626.         mov   ax, cx
  627. ;
  628. ; Set new value of file pointer
  629. ;
  630. Cr_Cnt:
  631.         cwd
  632.         add   Cnt_L, ax
  633.         adc   Cnt_H, dx
  634. ;
  635.         mov   h_cnt, 1     ; it's not first block
  636. ;
  637. ; Set buffer variables
  638. ;
  639.         mov   dx, 0        ; offset buff
  640.         mov   b_ptr, dx
  641.         mov   buf_lt, ax
  642.         mov   t_buf, ax
  643.         mov   h_buf, 0
  644.         mov   cur_cnt, 0
  645.         push  ds
  646.         pop   es
  647.         mov   di, offset array
  648.         mov   ax, 0
  649.         mov   cx, 23
  650.         rep stosw          ; Clear array
  651. ;
  652.         xor   ax, ax
  653. ;
  654. Rt_exit:
  655.         pop   di
  656.         pop   si
  657.         pop   dx
  658.         pop   cx
  659.         pop   bx
  660.         pop   es
  661.         ret
  662. rt_buf  endp
  663. ;
  664. lf_buf  proc  far
  665.         push  es
  666.         push  bx
  667.         push  cx
  668.         push  dx
  669.         push  si
  670.         push  di
  671. ;
  672.         cmp   h_cnt, 0
  673.         jne   Lf_set_fp
  674.         mov   ax, -1
  675.         jmp   Lf_exit
  676. Lf_set0:
  677.         mov   Cnt_L, 0
  678.         mov   Cnt_H, 0
  679.         mov   h_cnt, 0
  680.         jmp short Lf_mv_fp
  681. Lf_set_fp:
  682. ;
  683. ;  Set file pointer for LSEEK
  684. ;
  685.         mov   ax, buf_lt    ; move back to skip this buffer
  686.         cwd
  687.         sub   Cnt_L, ax
  688.         sbb   Cnt_H, dx
  689. ;
  690.         sub   Cnt_L, BUF_SIZ
  691.         sbb   Cnt_H, 0
  692.         js    Lf_set0
  693. ;
  694. Lf_mv_fp:
  695.         mov   cx, Cnt_H
  696.         mov   dx, Cnt_L
  697.         @MovePtrAbs fd
  698. ;
  699. ; Read prev. block
  700. ;
  701.         push  ds
  702.         mov   ax, BuffSeg
  703.         @Read 0, BUF_SIZ, fd, ax
  704.         pop   ds
  705.         jnc   Lf_Chk_cnt
  706.         mov   ax, -1
  707.         jmp   short Lf_exit
  708. SkLstStr:
  709.         push  ax
  710.         mov   di, ax         ; offset buff
  711.         mov   ax, BuffSeg
  712.         mov   es, ax
  713.         mov   al, 0ah
  714.         std
  715.     repne scasb
  716.         pop   ax
  717.         mov   b_ptr, di
  718.         jmp   short SetBufVars
  719. Lf_Chk_cnt:
  720.         mov   cx, ax
  721.         cmp   h_cnt, 0    ; it's first buffer ?
  722.         je    SkLstStr
  723.         push  ax
  724.         cwd
  725.         add   Cnt_L, ax    ; new
  726.         adc   Cnt_H, dx    ; file pointer
  727. ;
  728.         mov   di, 0        ; offset buff
  729.         mov   al, 0ah
  730.         push  ds
  731.         pop   es
  732.         cld
  733.     repne scasb
  734.         pop   ax
  735. ;
  736.         mov   dx, ax         ; offset buff
  737.         mov   b_ptr, dx   ; b_ptr points to tail of buffer
  738. ;
  739. ; Set buffer variables
  740. ;
  741. SetBufVars:
  742.         mov   t_cnt, 0
  743.         cmp   ax, BUF_SIZ
  744.         jne   Lf_contin
  745.         mov   t_cnt, 1    ; it's not last buffer
  746. Lf_contin:
  747.         mov   buf_lt, cx
  748.         mov   h_buf, cx
  749.         mov   t_buf, 0
  750.         mov   cur_cnt, 0
  751.         push  ds
  752.         pop   es
  753.         mov   di, offset array
  754.         mov   ax, 0
  755.         mov   cx, 23
  756.         cld
  757.         rep stosw          ; Clear array
  758. ;
  759.         xor   ax, ax
  760. ;
  761. Lf_exit:
  762.         pop   di
  763.         pop   si
  764.         pop   dx
  765.         pop   cx
  766.         pop   bx
  767.         pop   es
  768.         ret
  769. lf_buf  endp
  770. ;
  771. scroll  proc  far
  772.         push  es
  773.         push  bx
  774.         push  cx
  775.         push  dx
  776. ;
  777.         cmp   al, 1
  778.         jne   Scr_dn
  779.         @Scroll -1, attrib, U_X, U_Y+2, U_X+X_SIZ-3, U_Y+Y_SIZ-3
  780.         jmp short Scr_exit
  781. Scr_dn:
  782.         cmp   al, -1
  783.         jne   Cl_w
  784.         @Scroll 1, attrib, U_X, U_Y+2, U_X+X_SIZ-3, U_Y+Y_SIZ-3
  785.         jmp short Scr_exit
  786. Cl_w:
  787.         @Scroll -BOTTOM, attrib, U_X, U_Y+2, U_X+X_SIZ-3, U_Y+Y_SIZ-3
  788. ;
  789. Scr_exit:
  790.         pop   dx
  791.         pop   cx
  792.         pop   bx
  793.         pop   es
  794. ;
  795.         mov   ax, 0
  796.         ret
  797.  
  798. scroll  endp
  799. ;
  800. map_str proc  far
  801.         push  es
  802.         push  cx
  803.         mov   dx, v_addr
  804.         mov   es, dx
  805.         mov   di, w_off
  806.         add   di, (160 + 1) * 2
  807.         mov   bx, 160
  808.         mul   bx
  809.         add   di, ax
  810.         mov   si, offset str
  811.         mov   cx, str_lt
  812.         cmp   cx, 0
  813.         je    Map_exit
  814.         cmp   cx, X_SIZ - 2
  815.         jb    Map_contin
  816.         mov   cx, X_SIZ - 2
  817. Map_contin:
  818.         mov   ah, attrib
  819.         cld
  820. Map_cycl:
  821.         lodsb
  822.         cmp   al, 31
  823.         ja    StoreAL
  824.         mov   al, 32
  825. StoreAL:
  826.         stosw
  827.         loop  Map_cycl
  828. ;
  829. Map_exit:
  830.         mov   ax, 0
  831.         pop   cx
  832.         pop   es
  833.         ret
  834. map_str endp
  835. ;
  836. deact_w proc  far
  837.         push  es
  838. ;
  839. ; Restory the window
  840. ;
  841.         mov   si, offset w_save
  842.         mov   ax, v_addr
  843.         mov   es, ax
  844.         mov   di, w_off
  845.         mov   cx, Y_SIZ
  846. R_cycl:
  847.         push  cx
  848.         push  di
  849.         mov   cx, X_SIZ * 2
  850.         cld
  851.         rep movsb
  852.         pop   di
  853.         add   di, 160
  854.         pop   cx
  855.         loop  R_cycl
  856. ;
  857.         mov   ax, 0
  858.         pop   es
  859.         ret
  860. deact_w endp
  861. cal_cnt proc  far
  862.         push  es
  863.         push  cx
  864.         push  bx
  865. ;
  866. ; Calculate the total length of mapped strings
  867. ;
  868.         xor   cx, cx
  869.         mov   cl, cur_ln
  870.         inc   cl          ; cur_ln + 1
  871.         mov   bx, offset array
  872.         xor   ax, ax
  873. Calc_cnt:
  874.         add   ax, word ptr [bx]
  875.         add   bx, 2
  876.         loop  Calc_cnt
  877. ;
  878.         mov   cur_cnt, ax
  879. ;
  880.         pop   bx
  881.         pop   cx
  882. ;
  883.         mov   ax, 0
  884.         pop   es
  885.         ret
  886. cal_cnt endp
  887. nonek   proc  far
  888.         mov   ax, 0
  889.         ret
  890. nonek   endp
  891. SetVMem proc  far
  892.         push  es
  893.         @GetMode
  894.         mov   v_page, bh
  895.         cmp   al, 2
  896.         jne   M3
  897.         mov   v_addr, 0b800h
  898.         jmp  short S_win
  899. M3:
  900.         cmp   al, 3
  901.         jne   M7
  902.         mov   v_addr, 0b800h
  903.         jmp  short S_win
  904. M7:
  905.         cmp   al, 7
  906.         jne   Err_exit
  907.         mov   v_addr, 0b000h
  908.         jmp  short S_win
  909. Err_exit:
  910.         mov   ax, -1
  911.         pop   es
  912.         ret
  913. ;
  914. S_win:
  915.         xor   ax, ax
  916.         pop   es
  917.         ret
  918. SetVMem endp
  919. GetFN   proc  far
  920.         push  es
  921. ;
  922.         push  ds
  923.         mov   ax, ds
  924.         mov   es, ax       ; ES -> data segment
  925.         mov   ax, v_addr
  926.         mov   ds, ax       ; DS -> video memory
  927.         mov   di, offset svline
  928.         mov   si, 24 * 160 ; offset to last line
  929.         mov   cx, 80       ; save full line
  930.         cld
  931.         rep   movsw
  932. ;
  933.         pop   ds
  934.         mov   es, ax
  935.         mov   ah, attrib1
  936.         mov   al, 32
  937.         mov   di, 24 * 160 ; offset to last line
  938.         mov   cx, 80       ; save full line
  939.         cld
  940.         rep   stosw        ; clear the last line
  941. ;
  942.         mov   bx, offset dcl1
  943.         mov   cx, dcl1lt
  944.         mov   di, 24 * 160 ; offset to last line
  945. SetDcl1:
  946.         mov   al, byte ptr ds:[bx]
  947.         stosw
  948.         inc   bx
  949.         loop  SetDcl1
  950. ;
  951.         mov   si, di       ; save di
  952.         mov   bx, offset path
  953.         mov   dh, ah       ; save attrib1
  954. GetString:
  955.         mov   ah, 0
  956.         int   16h          ; read char. from keyb.
  957.         cmp   al, 0dh      ; Enter
  958.         je    SetFN_exit
  959.         cmp   ah, 1        ; ESC
  960.         jne   TestBS
  961.         mov   di, si       ; restory DI
  962.         mov   cx, X_SIZ - 2 - dcl1lt
  963.         mov   ah, dh
  964.         mov   al, 32
  965.         cld
  966.         rep   stosw        ; clear the "tail" of string
  967.         mov   di, si       ; restory DI
  968.         mov   bx, offset path
  969.         mov   byte ptr ds:[bx], 0
  970.         jmp short GetString
  971. TestBS:
  972.         cmp   ah, 0eh      ; backspace ?
  973.         jne   RestAttr
  974.         cmp   si, di
  975.         je    GetString
  976.         sub   di, 2
  977.         mov   ah, dh
  978.         mov   al, 32
  979.         stosw
  980.         sub   di, 2        ; clear last shar.
  981.         dec   bx
  982.         mov   byte ptr [bx], 0
  983.         jmp short GetString
  984. RestAttr:
  985.         mov   ah, dh       ; restory attrib1
  986.         stosw
  987.         mov   byte ptr ds:[bx], al
  988.         inc   bx
  989.         jmp  short GetString
  990. SetFN_exit:
  991.         mov  byte ptr ds:[bx], 0
  992. ;
  993.         mov   si, offset svline
  994.         mov   di, 24 * 160 ; offset to last line
  995.         mov   cx, 80       ; rest. full line
  996.         cld
  997.         rep   movsw        ; rest. the last line
  998. ;
  999.         pop   es
  1000.         xor   ax, ax
  1001.         ret
  1002. GetFN   endp
  1003. ;
  1004. ResetFL proc  far
  1005.         cmp   fd, 0
  1006.         je    SetFirstB
  1007.         @ClosFil fd
  1008.         mov   sksave, 255
  1009. SetFirstB:
  1010.         call far ptr  deact_w
  1011. ResetScr:
  1012.         call far ptr  set_scr0
  1013.         cmp   ax, 0
  1014.         je    ResetExit
  1015.         call far ptr  MapErr
  1016.         jmp short ResetScr
  1017. ;
  1018. ResetExit:
  1019.         xor   ax, ax
  1020.         ret
  1021. ResetFL endp
  1022. FilTitle proc  far
  1023.         push  es
  1024. ;
  1025.         mov   ax, v_addr
  1026.         mov   es, ax
  1027. ; Clear tile line
  1028.         mov   ah, attrib2
  1029.         mov   al, 32
  1030.         mov   di, w_off
  1031.         add   di, 162
  1032.         mov   cx, X_SIZ - 2
  1033.         cld
  1034.         rep   stosw
  1035. ;
  1036.         mov   si, offset dcl0
  1037.         mov   di, w_off
  1038.         add   di, 162
  1039.         mov   cx, dcl0lt
  1040. FillT:
  1041.         lodsb
  1042.         stosw               ; Map 'File : '
  1043.         loop  FillT
  1044. ;
  1045.         push  ds
  1046.         lds   si, dword ptr [bp + 6]
  1047. FilPath:
  1048.         lodsb
  1049.         cmp   al, 0         ; end_of_string ?
  1050.         je    FillExit
  1051.         stosw
  1052.         jmp short FilPath
  1053. ;
  1054. FillExit:
  1055.         pop   ds
  1056.         pop   es
  1057.         xor   ax, ax
  1058.         ret
  1059. FilTitle endp
  1060. MapErr  proc  far
  1061.         push  es
  1062. ;
  1063.         push  ds
  1064.         mov   ax, ds
  1065.         mov   es, ax       ; ES -> data segment
  1066.         mov   ax, v_addr
  1067.         mov   ds, ax       ; DS -> video memory
  1068.         mov   di, offset svline
  1069.         mov   si, 24 * 160 ; offset to last line
  1070.         mov   cx, 80       ; save full line
  1071.         cld
  1072.         rep   movsw
  1073. ;
  1074.         pop   ds
  1075.         mov   es, ax
  1076.         mov   ah, attrib3
  1077.         mov   al, 32
  1078.         mov   di, 24 * 160 ; offset to last line
  1079.         mov   cx, 80       ; save full line
  1080.         cld
  1081.         rep   stosw        ; clear the last line
  1082. ;
  1083.         mov   bx, offset dcl2
  1084.         mov   cx, dcl2lt
  1085.         mov   di, 24 * 160 ; offset to last line
  1086. SetDcl2:
  1087.         mov   al, byte ptr ds:[bx]
  1088.         stosw
  1089.         inc   bx
  1090.         loop  SetDcl2
  1091. ;
  1092.         mov ah, 0
  1093.         int 1ah
  1094.         add dx, 36   ; 2 sec
  1095.         mov bx, dx
  1096.  Repeat:
  1097.         int 1ah
  1098.         cmp dx, bx
  1099.         jne Repeat
  1100. ;
  1101.         mov   si, offset svline
  1102.         mov   di, 24 * 160 ; offset to last line
  1103.         mov   cx, 80       ; rest. full line
  1104.         cld
  1105.         rep   movsw        ; rest. the last line
  1106. ;
  1107.         pop   es
  1108.         xor   ax, ax
  1109.         ret
  1110. MapErr  endp
  1111.         end
  1112.